#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_iter1.py
# author: 马国鑫
# datetime:2022/4/7 15:16
# software: PyCharm

"""
this is function  description 
"""

# import module your need

# 判断他是不是可迭代对象
from collections.abc import Iterable

# list1 = [1, 2, 3, 4]
# print(isinstance(list1, Iterable))

# 通过iter获取迭代器
# 再通过next(迭代器)获取元素


# data_list = [1, 3, 5, 6, 7]
# # 获取迭代器
# list_iterator = iter(data_list)
# # 获取元素
# value = next(list_iterator)
# print(value)
# value = next(list_iterator)
# print(value)
# value = next(list_iterator)
# print(value)
# value = next(list_iterator)
# print(value)
# value = next(list_iterator)
# print(value)
# value = next(list_iterator)  # 再获取就会报出异常
# print(value)


# 自定义迭代器类
class MyIterator(object):
    def __iter__(self):
        pass

    def __next__(self):
        pass


my_iterator = MyIterator()
print(isinstance(my_iterator, Iterable))
